<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../comm/tag.jsp" %>

<script>
	
	var $menu_grid = $('#menu_grid');
	$menu_grid.datagrid({
		width:'100%',
		height:'100%',
		border:false,
		title:'菜单管理',
	    iconCls:'icon-edit', //图标
	    url: '${ctx}/menu/getPage.do',
	    method: 'POST',
	    //queryParams: { 'id': id },
	    idField: 'menuId',
	    striped: true,
	    fitColumns: true,
	    loadMsg:'数据加载中......',
	    singleSelect: false,
	    rownumbers: true,
	    pagination: true,
	    fit:true,
	    nowrap: true,
	    pageSize: 15,
	    pageList: [15,30, 50, 100, 150, 200],
	    showFooter: true,
	    columns: [[
	        { field: 'ck', checkbox: true },
	        { field: 'menuId', width:'20%', title: '菜单ID',align: 'center' },
	        { field: 'menuCode',width:'30%', title: '菜单代码',align: 'center' },
	        { field: 'menuName',width:100, title: '菜单名称', align: 'left' }
	    ]],
		onLoadSuccess:function(){
			$('#menu_grid').datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
		},
	    onBeforeLoad: function (param) {
	    	
	    },
	    onLoadError: function () {
	        
	    },
	    onClickCell: function (rowIndex, field, value) {
	        
	    },
	    toolbar:'#menu_grid_toolbar'
	});
	
		
	function gotoAdd_menu(){
		$.openWin({    
			gridId:"menu_grid",
		    href:'menu/gotoAdd.do',
		    title:'添加菜单'
		});  
	}
	
	function delete_menu(){
		$.doDelete("menu_grid","menu/delete.do",{});
	}
	
	function gotoUpd_menu(){
		var row = $menu_grid.datagrid("getSelected");
		if(row== null){
			$.alert('请选择一个要修改的数据','N');
		} else {
			$.openWin({    
				gridId:"menu_grid",
			    href:'menu/gotoUpd.do?menuId='+row.menuId,
			    title:'修改菜单'
			});  
		}
	}
</script>
<div style="height:100%;width:100%;overflow:hidden;">
	<div id="menu_grid_toolbar" style="width:100%;height:25%">
		<div class="easyui-layout" fit="true">
			<div region="center" style="padding-top:20px;padding-left:30px;border:none;">
				<form id="menu_grid_search_form">
					菜单名称: <input class="easyui-textbox" name="menuName" style="width:100px">
					菜单代码: <input class="easyui-textbox" name="menuCode" style="width:100px">
					<a href="javascript:void(0);" class="easyui-linkbutton" onclick="doSearch('menu_grid')" iconCls="icon-search">查询</a>
				</form>
			</div>
			<div region="south" class="datagrid-toolbar">
				<a href="javascript:void(0);" class="easyui-linkbutton" onclick="gotoAdd_menu()" iconCls="icon-add" plain="true">添加</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="gotoUpd_menu()" plain="true">修改</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="delete_menu()" plain="true">删除</a>
			</div>
		</div>
	</div>
	<table id="menu_grid">
	</table>
</div>